

		

		function nowTime(that, dataList) {//时间函数   //时间数据数组 
			// 获取当前时间，同时得到活动结束时间数组
			let newTime = new Date().getTime();
			for (var i = 0; i < dataList.length; i++) {
				var createtime = dataList[i].shareCreateTime //创建时间 日期
				var endTime = dataList[i].survivalTime;//获取结束时间 小时
				endTime = createtime + endTime
				//console.log(time)
				var day = 0, hour = 0, minute = 0, second = 0;
				if (endTime - newTime > 0) {
					let time = (endTime - newTime) / 1000;
					day = Math.floor(time / (60 * 60 * 24));
					hour = Math.floor(time / (60 * 60)) - (day * 24);
					minute = Math.floor(time / 60) - (day * 24 * 60) - (hour * 60);
					second = Math.floor(time) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
					if (hour <= 9) hour = '0' + hour;
					if (minute <= 9) minute = '0' + minute;
					if (second <= 9) second = '0' + second;
					dataList[i].survivalTime--;
					var str = hour + ':' + minute + ':' + second
					console.log(str)      
				} else {
					var str = "已结束";
					clearInterval(timer);
				}
				 console.log(str);  
				dataList[i].timers = str;//在数据中添加timers参数名，把时间放进去  
			}
			that.setData({
				wearList: dataList
			})
		}


		function onld(){

			nowTime();
			var timer = setInterval(nowTime, 1000);
		}

module.exports = {
	nowTime: nowTime,
}
